package com.finance.rule.export;

import com.finance.util.export.ExcelHead;
import lombok.Data;
import org.apache.commons.lang.StringUtils;

import java.math.BigDecimal;


@Data
public class NewPieceRuleImportTemplateBean {

    @ExcelHead(name="规则模式")
    private String patternRuleImport;
    private String patternRule;

    @ExcelHead(name="供应商名称")
    private String supplierCodeImport;
    private String supplierCode;

    @ExcelHead(name="承运商名称")
    private String carrierCodeImport;
    private String carrierCode;

    @ExcelHead(name="目的地省份")
    private String toProvinceImport;
    private String toProvince;

    @ExcelHead(name="目的市")
    private String toCityImport;
    private String toCity;

    @ExcelHead(name="区域类型")
    private String regionIdImport;
    private String regionId;

    @ExcelHead(name="结算类型")
    private String settlementTypeImport;
    private String settlementType;

    @ExcelHead(name="发货省份")
    private String fromProvinceImport;
    private String fromProvince;

    @ExcelHead(name="发货城市")
    private String fromCityImport;
    private String fromCity;

    @ExcelHead(name="首件价格")
    private String firstPiecePrice;

    @ExcelHead(name="拖件价格")
    private String secondPrice;

    @ExcelHead(name="代收金额首件")
    private String codMajor;

    @ExcelHead(name="代收金额拖件")
    private String codDrag;

    @ExcelHead(name="配送类型首件")
    private String directionMajor;

    @ExcelHead(name="配送类型拖件")
    private String directionDrag;

    @ExcelHead(name="时效要求首件")
    private String expressScheduleTypeMajor;

    @ExcelHead(name="时效要求拖件")
    private String expressScheduleTypeDrag;

    @ExcelHead(name="温度级别首件")
    private String temperatureMajor;

    @ExcelHead(name="温度级别拖件")
    private String temperatureDrag;

    @ExcelHead(name="重量")
    private String weight;

    @ExcelHead(name="重量首件")
    private String weightMajor;

    @ExcelHead(name="重量拖件")
    private String weightDrag;

    @ExcelHead(name="菜鸟驿站首件")
    private String cainiaoMajor;

    @ExcelHead(name="菜鸟驿站拖件")
    private String cainiaoDrag;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof NewPieceRuleImportTemplateBean)) {
            return false;
        }
        NewPieceRuleImportTemplateBean that = (NewPieceRuleImportTemplateBean) o;
        if (null == supplierCodeImport ) {
            if(null != that.supplierCodeImport) {
                return false;
            }
        } else {
            if (!supplierCodeImport.equals(that.supplierCodeImport)) {
                return false;
            }
        }
        if (null == patternRuleImport ) {
            if(null != that.patternRuleImport) {
                return false;
            }
        } else {
            if (!patternRuleImport.equals(that.patternRuleImport)) {
                return false;
            }
        }
        /*if (null == carrierCodeImport ) {
            if(null != that.carrierCodeImport) {
                return false;
            }
        } else {
            if (!carrierCodeImport.equals(that.carrierCodeImport)) {
                return false;
            }
        }*/
        if (null == toProvinceImport ) {
            if(null != that.toProvinceImport) {
                return false;
            }
        } else {
            if (!toProvinceImport.equals(that.toProvinceImport)) {
                return false;
            }
        }
        if (null == toCityImport ) {
            if(null != that.toCityImport) {
                return false;
            }
        } else {
            if (!toCityImport.equals(that.toCityImport)) {
                return false;
            }
        }
        if (null == fromProvinceImport ) {
            if(null != that.fromProvinceImport) {
                return false;
            }
        } else {
            if (!fromProvinceImport.equals(that.fromProvinceImport)) {
                return false;
            }
        }
        if (null == fromCityImport ) {
            if(null != that.fromCityImport) {
                return false;
            }
        } else {
            if (!fromCityImport.equals(that.fromCityImport)) {
                return false;
            }
        }
        if (null == regionIdImport ) {
            if(null != that.regionIdImport) {
                return false;
            }
        } else {
            if (!regionIdImport.equals(that.regionIdImport)) {
                return false;
            }
        }
        if (null == settlementTypeImport ) {
            if(null != that.settlementTypeImport) {
                return false;
            }
        } else {
            if (!settlementTypeImport.equals(that.settlementTypeImport)) {
                return false;
            }
        }
        return true;
    }

    @Override
    public int hashCode() {
        int result = 3;
        result = 32 * result + (null == supplierCodeImport ? 2: supplierCodeImport.hashCode());
        //result = 32 * result + (null == carrierCodeImport ? 2: carrierCodeImport.hashCode());
        result = 32 * result + (null == patternRuleImport ? 2: patternRuleImport.hashCode());
        result = 32 * result + (null == toProvinceImport ? 2: toProvinceImport.hashCode());
        result = 32 * result + (null == toCityImport ? 2: toCityImport.hashCode());
        result = 32 * result + (null == fromProvinceImport ? 2: fromProvinceImport.hashCode());
        result = 32 * result + (null == fromCityImport ? 2: fromCityImport.hashCode());
        result = 32 * result + (null == regionIdImport ? 2: regionIdImport.hashCode());
        result = 32 * result + (null == settlementTypeImport ? 2: settlementTypeImport.hashCode());
        return result;
    }

    public NewPieceRuleExcel toNewPieceRuleExcel(){
        NewPieceRuleExcel newPieceRuleExcel = new NewPieceRuleExcel();
        newPieceRuleExcel.setSupplierCodeImport(this.getSupplierCodeImport());
        //newPieceRuleExcel.setCarrierCodeImport(this.getCarrierCodeImport());
        newPieceRuleExcel.setPatternRuleImport(this.getPatternRuleImport());
        newPieceRuleExcel.setToProvinceImport(this.getToProvinceImport());
        newPieceRuleExcel.setToCityImport(this.getToCityImport());
        newPieceRuleExcel.setRegionIdImport(this.getRegionIdImport());
        newPieceRuleExcel.setSettlementTypeImport(this.getSettlementTypeImport());
        newPieceRuleExcel.setFromProvinceImport(this.getFromProvince());
        newPieceRuleExcel.setFromCityImport(this.getFromCity());

        newPieceRuleExcel.setFirstPiecePrice(StringUtils.isNotBlank(this.getFirstPiecePrice())? new BigDecimal(this.getFirstPiecePrice()):null);
        newPieceRuleExcel.setSecondPrice(StringUtils.isNotBlank(this.getSecondPrice())? new BigDecimal(this.getSecondPrice()):null);
        newPieceRuleExcel.setCodMajor(StringUtils.isNotBlank(this.getCodMajor())? new BigDecimal(this.getCodMajor()):null);
        newPieceRuleExcel.setCodDrag(StringUtils.isNotBlank(this.getCodDrag())? new BigDecimal(this.getCodDrag()):null);
        newPieceRuleExcel.setDirectionMajor(StringUtils.isNotBlank(this.getDirectionMajor())? new BigDecimal(this.getDirectionMajor()):null);
        newPieceRuleExcel.setDirectionDrag(StringUtils.isNotBlank(this.getDirectionDrag())? new BigDecimal(this.getDirectionDrag()):null);
        newPieceRuleExcel.setExpressScheduleTypeMajor(StringUtils.isNotBlank(this.getExpressScheduleTypeMajor())? new BigDecimal(this.getExpressScheduleTypeMajor()):null);
        newPieceRuleExcel.setExpressScheduleTypeDrag(StringUtils.isNotBlank(this.getExpressScheduleTypeDrag())? new BigDecimal(this.getExpressScheduleTypeDrag()):null);
        newPieceRuleExcel.setTemperatureMajor(StringUtils.isNotBlank(this.getExpressScheduleTypeMajor())? new BigDecimal(this.getExpressScheduleTypeMajor()):null);
        newPieceRuleExcel.setTemperatureDrag(StringUtils.isNotBlank(this.getExpressScheduleTypeDrag())? new BigDecimal(this.getExpressScheduleTypeDrag()):null);
        newPieceRuleExcel.setWeight(StringUtils.isNotBlank(this.getWeight())? new BigDecimal(this.getWeight()):null);
        newPieceRuleExcel.setWeightMajor(StringUtils.isNotBlank(this.getWeightMajor())? new BigDecimal(this.getWeightMajor()):null);
        newPieceRuleExcel.setWeightDrag(StringUtils.isNotBlank(this.getWeightDrag())? new BigDecimal(this.getWeightDrag()):null);
        newPieceRuleExcel.setCainiaoMajor(StringUtils.isNotBlank(this.getCainiaoMajor())? new BigDecimal(this.getCainiaoMajor()):null);
        newPieceRuleExcel.setCainiaoDrag(StringUtils.isNotBlank(this.getCainiaoDrag())? new BigDecimal(this.getCainiaoDrag()):null);
        return newPieceRuleExcel;
    }

}
